package com.lzy.mall.order.controller;


import com.lzy.mall.common.utils.PageUtils;
import com.lzy.mall.common.utils.ResultUtils;
import com.lzy.mall.order.entity.OmsOrder;
import com.lzy.mall.order.service.OmsOrderService;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 订单(OmsOrder)表控制层
 *
 * @author lzy
 * @since 2021-08-25 11:22:38
 */
@RestController
@RequestMapping("order")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class OmsOrderController {
    private final OmsOrderService orderService;

    /**
     * 查询当前登录的用户的所有订单信息
     */
    @GetMapping("/listWithItem/{pageNum}")
    ResultUtils listWithItem(@PathVariable("pageNum") Long pageNum){
        PageUtils page = orderService.queryPageWithItem(pageNum);
        return ResultUtils.ok().put("page", page);
    }

    @GetMapping("/status/{orderSn}")
    public ResultUtils getOrderBySn(@PathVariable("orderSn") String orderSn){
        OmsOrder order = orderService.getOrderBySn(orderSn);
        System.out.println("根据订单号查询订单：" + order);
        return ResultUtils.ok().setData(order);
    }
}
